<?php
header("Content-type:text/html; charset=utf-8");
require_once ('include/conn.php');
require_once ('system.class.php');
/*供首页模版使用*/
function channellist($args, $content, &$smarty){
	$channel=explode(",", $args['channel_id']);
	$num=count($channel);
	
	$children='false';
	if(!empty($args['children']))
	$children=$args['children'];
    for($i=0;$i<$num;$i++){
	$sql_get_channel_infor="select channel_name,channel_visit_path from channel where channel_id=$channel[$i]";
	$result_get_channel_infor=mysql_query($sql_get_channel_infor);
	$row_get_channel_infor=mysql_fetch_row($result_get_channel_infor);
	$channel_id=$channel[$i];
	$arr[$channel_id]['id']=$i+1;
	$arr[$channel_id]['channel_id']=$channel_id;
	$arr[$channel_id]['channel_name']=$row_get_channel_infor[0];
	$arr[$channel_id]['url']=CIE."/channel.php?channel_id=$channel_id";

	
	if($children=='true'){
	$sql_get_child_channel_infor="select channel_id,channel_name,channel_visit_path from channel where pre_id=$channel[$i] order by channel_id limit 0,5";
	$result_get_child_channel_infor=mysql_query($sql_get_child_channel_infor);
	while($row_get_child_channel_infor=mysql_fetch_row($result_get_child_channel_infor)){
		$child_id=$row_get_child_channel_infor[0];
		$tmp[$child_id]['channel_id']=$child_id;
		$tmp[$child_id]['channel_name']=$row_get_child_channel_infor[1];
		$tmp[$child_id]['url']=CIE."/channel.php?channel_id=$child_id";
		
	}
	if(empty($tmp)){
		$tmp=null;
	}
	$arr[$channel_id]['child_channel_infor']=$tmp;
	$tmp=array();
	}
	}
	if(empty($arr)){
		$arr=null;
	}
	$smarty->assign("channel_list",$arr);
	//print_r($arr);
	return $content;
}